// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "PaperCharacter.h"
#include "Structs/PlayerAnimation.h"
#include "SoulKnightPaperCharacter.generated.h"

enum class E_FaceToDirection : uint8;
struct FPlayerAnimation;
enum class E_MovementState : uint8;
struct FInputActionValue;
class UInputMappingContext;
class UInputAction;
class UPaperFlipbook;

/**
 * 
 */
UCLASS()
class SOULKNIGHT_API ASoulKnightPaperCharacter : public APaperCharacter
{
	GENERATED_BODY()

public:
	ASoulKnightPaperCharacter();
	virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
	virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;

	void Move(const FInputActionValue& InputValue);
	void MoveCompleted(const FInputActionValue& InputValue);

public:
	UFUNCTION(Server, Reliable)
	void ServerSetMovementState(E_MovementState State);

	UFUNCTION()
	void OnRep_MovementState();

protected:
	void MovementStateChanged();

protected:
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "EnhancedInput")
	TObjectPtr<UInputMappingContext> IMC_Move;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "EnhancedInput|Action")
	TObjectPtr<UInputAction> IA_Move;
	
	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Flipbook")
	FPlayerAnimation PlayerAnimFlipbook;

protected:
	// 移动状态
	UPROPERTY(ReplicatedUsing = OnRep_MovementState, EditDefaultsOnly, BlueprintReadWrite, Category = "Movement")
	E_MovementState MovementState;

	// 面朝向
	E_FaceToDirection FaceToDirection;
};
